﻿using System.Net.Mail;
using CustomerContactSystem.Core.Infrastructure.Configuration;
using CustomerContactSystem.Core.Infrastructure.Email;

namespace CustomerContactSystem.Core.AppServices.Email {
    public class SmtpEmailService : IEmailService {
        private readonly IApplicationSettings _settings;

        public SmtpEmailService(IApplicationSettings settings) {
            _settings = settings;
        }

        public void SendEmail(BaseEmail email) {
            var client = new SmtpClient(_settings.SmptServerAddress);
            var mail = new MailMessage(email.SentFrom, email.Recipient, email.Subject, email.MessageContent)
                            {IsBodyHtml = email.IsHtml};
            client.Send(mail);
        }
    }
}